﻿using System;
using System.Collections.Generic;
using System.IO;
using Windows.UI.Xaml.Media.Imaging;
using System.Linq;
using System.Windows.Input;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Input;
using Windows.UI.Core;
using System.Threading;
using System.Collections.Concurrent;
namespace RoboRun
{
    class RobotAnimation
    {
        public static async void straightAnimationEast3x3()
        {
          
                while (GameplayScreen.animationmarker == true)
                {
                    for (int i = 1; i <= 8; i++)
                    {
                        GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/3X3Grid/EastRunning/" + i + ".png"), UriKind.Absolute
                  ));
                        await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                        if (i == 8)
                        {
                            i = 0;
                        }
                        if (GameplayScreen.animationmarker == false)
                        {
                            break;
                        }
                    }
            }
        }

        public static async void straightAnimationNorth3x3()
        {
           
                while (GameplayScreen.animationmarker == true)
                {
                    for (int i = 1; i <= 8; i++)
                    {
                        GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/3X3Grid/NorthRunning/" + i + ".png"), UriKind.Absolute
                  ));
                        await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                        if (i == 8)
                        {
                            i = 0;
                        }
                        if (GameplayScreen.animationmarker == false)
                        {
                            break;
                        }

                    }
                    //GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/3x3Grid/robotnorth.png", UriKind.Absolute
                // ));
                }
            

        }

        public static async void straightAnimationWest3x3()
        {
           
                while (GameplayScreen.animationmarker == true)
                {
                    for (int i = 1; i <= 8; i++)
                    {
                        GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/3X3Grid/WestRunning/" + i + ".png"), UriKind.Absolute
                  ));
                        await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                        if (i == 8)
                        {
                            i = 0;
                        }
                        if (GameplayScreen.animationmarker == false)
                        {
                            break;
                        }
                    }
                
            }

        }

        public static async void straightAnimationSouth3x3()
        {
            
                while (GameplayScreen.animationmarker == true)
                {
                    for (int i = 1; i <= 8; i++)
                    {
                        GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/3X3Grid/SouthRunning/" + i + ".png"), UriKind.Absolute
                  ));
                        await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                        if (i == 8)
                        {
                            i = 0;
                        }
                        if (GameplayScreen.animationmarker == false)
                        {
                            break;
                        }
                    }
                
            }

        }

        public static async void straightAnimationNorth4x4()
        {

            while (GameplayScreen.animationmarker == true)
            {
                for (int i = 1; i <= 8; i++)
                {
                    GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/4X4Grid/NorthRunning/" + i + ".png"), UriKind.Absolute
              ));
                    await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                    if (i == 8)
                    {
                        i = 0;
                    }
                    if (GameplayScreen.animationmarker == false)
                    {
                        break;
                    }

                }
                //GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/3x3Grid/robotnorth.png", UriKind.Absolute
                // ));
            }


        }

        public static async void straightAnimationEast4x4()
        {

            while (GameplayScreen.animationmarker == true)
            {
                for (int i = 1; i <= 8; i++)
                {
                    GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/4X4Grid/EastRunning/" + i + ".png"), UriKind.Absolute
              ));
                    await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                    if (i == 8)
                    {
                        i = 0;
                    }
                    if (GameplayScreen.animationmarker == false)
                    {
                        break;
                    }
                }
            }
        }

        public static async void straightAnimationSouth4x4()
        {

            while (GameplayScreen.animationmarker == true)
            {
                for (int i = 1; i <= 8; i++)
                {
                    GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/4X4Grid/SouthRunning/" + i + ".png"), UriKind.Absolute
              ));
                    await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                    if (i == 8)
                    {
                        i = 0;
                    }
                    if (GameplayScreen.animationmarker == false)
                    {
                        break;
                    }
                }

            }

        }

        public static async void straightAnimationWest4x4()
        {

            while (GameplayScreen.animationmarker == true)
            {
                for (int i = 1; i <= 8; i++)
                {
                    GameplayScreen.RobotSpriteRef.Source = new BitmapImage(new Uri(("ms-appx:///Assets/GameplayScreen/4X4Grid/WestRunning/" + i + ".png"), UriKind.Absolute
              ));
                    await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
                    if (i == 8)
                    {
                        i = 0;
                    }
                    if (GameplayScreen.animationmarker == false)
                    {
                        break;
                    }
                }

            }

        }


    }
}
